/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author TranDua
 */
public class Validate {

    private Pattern pattern;
    private Matcher matcher;
    private static final String Email_Pattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
//    private static final String Phone_Pattern = "\\d{3}-\\d{7}";

    public boolean validateEmail(final String email) {
        pattern = Pattern.compile(Email_Pattern);
        matcher = pattern.matcher(email);
        return matcher.matches();
    }
    public boolean validatePhone(final String phone) {
        pattern = Pattern.compile("0\\d{9,10}");
        matcher = pattern.matcher(phone);
        return matcher.matches();
    }
    
}
